fix: HTML export/parse round trip ignoring empty blocks (BLO-873) - #2931
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe HTML serializer now preserves empty inline blocks with an object replacement character. The HTML parser and Markdown exporter remove this marker. Export coverage includes an empty paragraph between two populated paragraphs. ChangesEmpty inline HTML preservation
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
We'll need to get this passing again before merging |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
Summary
This PR fixes empty paragraphs getting dropped when running to round trip of
blocksToHTMLLossy->tryParseHTMLToBlocks. The fix is to add a Unicode object replacement character to empty blocks' inline content elements when exporting to lossy HTML. This causes the blocks to be parsed instead of ignored without introducing any other changes in behaviour. Markdown export/parse works the same, and the character don't affect rendering the lossy HTML. For good measure though, the character is also stripped when parsing HTML to ensure full round-trip consistency.Closes #986
Rationale
Dropping empty blocks is a loss of information from the original document that I believe is never desirable for consumers. For this reason, Ive also opted to not make this behaviour configurable.
Changes
See above.
Impact
N/A
Testing
Added unit test case and updated existing HTML export snapshots.
Screenshots/Video
N/A
Checklist
Additional Notes
N/A
Summary by CodeRabbit
Bug Fixes
Tests